﻿// <copyright file="DesignHelper" company="DinamoGest, Lda">
// Copyright © 2009 All Right Reserved
// </copyright>
// <created>11/25/2009 7:30:34 PM</created>
namespace CollisionDetection.Extended
{
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Windows;

    /// <summary>
    /// Declares DesignHelper class.
    /// </summary>
    public static class DesignHelper
    {
        private static bool? _isInDesignMode;

        public static bool IsInDesignModeStatic
        {

            get
            {

                if (!_isInDesignMode.HasValue)
                {

#if DEBUG

#if SILVERLIGHT
                    
					_isInDesignMode = DesignerProperties.IsInDesignTool;
                    
#else

                    var prop = DesignerProperties.IsInDesignModeProperty;
                    _isInDesignMode = (bool)DependencyPropertyDescriptor
                                                .FromProperty(prop, typeof(FrameworkElement))
                                                .Metadata.DefaultValue;
                    // Just to be sure
                    if (!_isInDesignMode.Value && Process.GetCurrentProcess().ProcessName.StartsWith("devenv"))
                    {
                        _isInDesignMode = true;
                    }

#endif

#else

					_isInDesignMode = false;
					
#endif

                }

                return _isInDesignMode.Value;

            }

        } 
    }
}